import { defaultRoute } from "@/router/defaultRoute";
import { tabs, blank, page } from "@/layouts";
const localRouterMap = [
  {
    name: "Root",
    path: "/",
    component: tabs,
    redirect: "/wxUser", // 重定向
    children: [
      // {
      //   name: "Home",
      //   path: "/home",
      //   component: () => import("@/views/home/index"),
      //   hidden: false, // 是否设置了隐藏菜单
      //   meta: {
      //     title: "首页",
      //     icon: "home",
      //     invisible: false,
      //     target: "",
      //   },
      // },
      {
        name: "Admin",
        path: "/admin",
        redirect: "/admin/list", // 重定向
        component: page,
        meta: {
          title: "管理员管理",
          icon: "home",
          invisible: false,
          target: "",
        },
        children: [
          {
            name: "List",
            path: "/admin/list",
            component: () => import("@/views/sysAdmin"),
            meta: {
              title: "管理员列表",
              icon: "home",
              invisible: false,
              target: "",
            },
          },
          {
            name: "UserGroup",
            path: "/admin/userGroup",
            component: () => import("@/views/sysUserGroup"),
            meta: {
              title: "用户组列表",
              icon: "home",
              invisible: false,
              target: "",
            },
          },
        ],
      },
      {
        name: "Platform",
        path: "/platform",
        component: () => import("@/views/sysPlatform/index"),
        meta: {
          title: "平台管理",
          icon: "home",
          invisible: false,
          target: "",
        },
      },
      {
        name: "WxUser",
        path: "/wxUser",
        component: () => import("@/views/sysWxUser/index"),
        meta: {
          title: "微信管理",
          icon: "home",
          invisible: false,
          target: "",
        },
      },
    ],
  },
];

const router = {
  state: {
    routers: defaultRoute,
    addRouters: [],
  },
  mutations: {
    SET_ROUTERS: (state, routers) => {
      state.addRouters = routers;
      state.routers = defaultRoute.concat(routers);
    },
  },
  actions: {
    generateRoutes({ commit }, data) {
      return new Promise((resolve) => {
        // const { token } = data
        // generatorDynamicRouter(token).then(routers => {
        commit("SET_ROUTERS", localRouterMap);
        resolve();
        // })
      });
    },
  },
};

export default router;
